package com.wx.servlet;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.wx.service.DoctorService;
import com.wx.service.impl.DoctorServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class DepartmentServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html; charset=UTF-8");
        DoctorService doctorService=new DoctorServiceImpl();
        List<String> list=doctorService.getDepartments();
        ObjectMapper mapper=new ObjectMapper();
        mapper.writeValue(resp.getWriter(),list);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
}
